<?php
/**
 * Created by IntelliJ IDEA.
 * User: admin
 * Date: 3/29 0029
 * Time: 19:03
 */

namespace app\api\model;


use think\Model;

class Shop extends Model
{
    /**
     * 获取所有门店
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function getall(){
        return $this->join("y_merchant","y_merchant.id=y_shop.merchantid","left")->field("y_shop.*,y_merchant.mername")->select();
    }

    /**
     * 获取一个门店
     * @param $shopid
     * @return array|false|\PDOStatement|string|Model
     */
    public function getone($shopid){
        return $this->join("y_merchant","y_merchant.id=y_shop.merchantid","left")->field("y_shop.*,y_merchant.mername")->where(['y_shop.id'=>$shopid])->find();
    }

    /**
     * 获取一个商户下的所有门店
     * @param $merchantid
     */
    public function getonemer($merchantid){
        return $this->where(["merchantid"=>$merchantid])->select();
    }

    public function getname($shopid){
        return $this->where(["id"=>$shopid])->column("shopname")[0];
    }
}